package com.atguigu.tingshu.user.api;

import com.atguigu.tingshu.common.login.GuiGuLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.model.user.UserPaidTrack;
import com.atguigu.tingshu.user.service.UserInfoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("api/user/userInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserInfoApiController {

	@Autowired
	private UserInfoService userInfoService;
	@GetMapping("getUserInfo/{userId}")
	public Result<UserInfo> getUserInfo(@PathVariable Long userId){
		UserInfo userInfo =userInfoService.getById(userId);
		return Result.ok(userInfo);
	}
	@GuiGuLogin
	@GetMapping("isPaidAlbum/{albumId}")
	public Result<Boolean> isPaidAlbum(@PathVariable Long albumId){
		Boolean isPaid =userInfoService.isPaidAlbum(albumId);
		return Result.ok(isPaid);
	}
	@GuiGuLogin
	@GetMapping("getPaidTrackList/{albumId}")
	public Result<List<UserPaidTrack>> getPaidTrackList(@PathVariable Long albumId){
		List<UserPaidTrack> userPaidTrackList=userInfoService.getPaidTrackList(albumId);
		return Result.ok(userPaidTrackList);
	}

}

